package sunwin.yoms.service.person;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import sunwin.yoms.comm.YomsException;
import sunwin.yoms.dao.UserStateDao;
import sunwin.yoms.domain.person.UserStateDomain;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by watson on 2015/7/30.
 */
@Service
public class UserStateService {
    @Autowired
    private UserStateDao userStateDao;

    //查询
    public List<UserStateDomain> getUserState(UserStateDomain userStateDomain) {
        List<UserStateDomain> userStateDomains = userStateDao.getDomainCollection(userStateDomain);
        return userStateDomains;
    }

    //id查询
    public UserStateDomain getUserStateById(int userStateId) {
        return userStateDao.getDomainById(userStateId);
    }

    //总数
    public int getUserStateCount() {
        return userStateDao.getDomainCount();
    }

    //增加
    public void addUserState(UserStateDomain userStateDomain) throws YomsException {
        if (userStateDao.addDomain(userStateDomain) != 1) {
            throw new YomsException("增加用户状态失败");
        }
    }

    //更新
    public void upUserState(UserStateDomain userStateDomain) throws YomsException {
        if (userStateDao.updateDomain(userStateDomain) != 1) {
            throw new YomsException("更新状态失败");
        }
    }

    //删除
    public void deleteUserState(UserStateDomain userStateDomain) throws YomsException {
        if (userStateDao.deleteDomain(userStateDomain) != 1) {
            throw new YomsException("删除用户状态失败");
        }
    }
}
